import ij.IJ;
import ij.ImagePlus;
import ij.gui.NewImage;
import ij.plugin.PlugIn;
import ij.process.ImageProcessor;


import java.awt.Color;


import java.awt.Font;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;

import laplacianGrowthUtils.Grid2DPotential;

import pluginUtils.Doublet;
import pluginUtils.Punkt;
import pluginUtils.Quadrilatere;
import pluginUtils.Transformation;
import testpackage.Printer;


// Read a datafile and a image file, compute the distorted image for anamorphosis


public class Mosaique extends ImagePlus implements PlugIn{
	{Locale.setDefault(Locale.US); }
	
	
	private ImageProcessor primeIP; 
	private int X=2800,Y=2100; // image size
	
	
	
	
	
	
	
	
	public void run(String arg) {
		System.out.println("go");
		
		// Import original images
		// Location of the source image
		//ImagePlus imp = IJ.openImage("/tmp/Mona_Lisa.png");
		ImagePlus imp[][]=new ImagePlus[10][10]; 
		imp[0][0]=IJ.openImage("F:/Povray/144mini.jpg"); 
		imp[0][0].setTitle("PrimeIP");
		
	
		//System.out.println(imp); 
		primeIP=imp[0][0].getProcessor();
		X=primeIP.getWidth(); 
		Y=primeIP.getHeight(); 
		
        setStack(null, imp[0][0].getStack());
        setCalibration(imp[0][0].getCalibration()); 
		
        	show();
		
		
		

		// create a new image with the same size and copy the pixels of the original image
		ImagePlus inverted = NewImage.createRGBImage ("Inverted image", primeIP.getWidth()*27, primeIP.getHeight()*27, 1, NewImage.FILL_BLACK);
		ImageProcessor inv_ip = inverted.getProcessor();
		
		
		for(int i=0;i<inv_ip.getWidth();i++)
			for(int j=0;j<inv_ip.getHeight();j++)
			{   int col=ip.getPixel(i%X,j%Y);  
				inv_ip.putPixel(i,j,col); 
			}
		
		primeIP.setFont(new Font(null,Font.ITALIC,60));
		primeIP.setColor(Color.RED);
		primeIP.setLineWidth(10); 
	
		setProcessor("Verifying", primeIP);
		
	
		inverted.show();
		
		
		}
	}	

	